-
-
Notifications
You must be signed in to change notification settings - Fork 420
Handle non-ICRS coordinates in query functions #3164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3164 +/- ##
==========================================
+ Coverage 70.18% 70.27% +0.09%
==========================================
Files 232 232
Lines 19937 19973 +36
==========================================
+ Hits 13992 14037 +45
+ Misses 5945 5936 -9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4dc257f
to
f2bd777
Compare
4baa044
to
50648fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should live in the commons function, or you could use what we already have for simbad (_parse_coordinate_and_convert_to_icrs)?
(or also move the simbad one to commons? cc @ManonMarchand )
_parse_coordinate_and_convert_to_icrs
astroquery/mast/utils.py
Outdated
@@ -121,6 +121,32 @@ def resolve_object(objectname): | |||
return coordinates | |||
|
|||
|
|||
def parse_coordinates(coordinates): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should be a kwarg argument for commons.parse_coordinates
instead? e.g. to convert right at the end before returning the current output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean a parameter like return_frame
or something to that effect that you could pass in a value like 'ICRS' and get the coordinate back in whatever frame was given?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just made this change! I added a return_frame
parameter to utils.commons.parse_coordinates
that defaults to None
. If it is provided and the coordinates are not already in that frame, it will attempt to transform them. If the transformation fails, a warning is issued and the coordinates are returned as is, without the transformation.
Oh that methods only parses coordinates if I detect that they are written as a sim-script string. This is an old way of writing coordinates that only existed in the former Simbad interface (hence this is in Simbad's utils and not in commons). |
f83c591
to
0746ddf
Compare
69ca4b1
to
42597be
Compare
@bsipocz Pinging this PR again in case it was lost in the shuffle somewhere! I'll be offline from 3/26 - 4/3, but this isn't high priority, so no worries if you don't get around to it before then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments only. Thanks!
astroquery/utils/commons.py
Outdated
@@ -40,7 +40,7 @@ | |||
ASTROPY_LT_7_1_1 = not minversion('astropy', '7.1.1') | |||
|
|||
|
|||
def parse_coordinates(coordinates): | |||
def parse_coordinates(coordinates, return_frame=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this mandatory kwarg please
def parse_coordinates(coordinates, return_frame=None): | |
def parse_coordinates(coordinates, *, return_frame=None): |
astroquery/utils/commons.py
Outdated
except ValueError: | ||
warnings.warn(f"Failed to transform coordinates to requested frame: {return_frame}.", InputWarning) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel should let the exception propagate, after all this will only be triggered when return frame is explicitly asked for, thus a problem should be surfaced up to the user/module level
CHANGES.rst
Outdated
@@ -239,6 +239,8 @@ Infrastructure, Utility and Other Changes and Additions | |||
- Removed usage of the astropy TestRunner, therefore the unadvertised | |||
``astroquery.test()`` functionality. [#3215] | |||
|
|||
- ``return_frame`` parameter in ``utils.commons.parse_coordinates`` returns coordinates in the specified frame. [#3164] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rebase to remove the merge commit and to squash out the changelog iterations, and to put this into the 0.4.11 section. Thanks!
ef8e8c3
to
43c951c
Compare
Updated and rebased! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately with the most recent mast merges this is now conflicting again. Could you please do a rebase again and make sure that the only diff in the changelog is the line for this PR?
Code looks good, so I'll merge once the rebase is done and it passes the remote tests.
Thanks.
CHANGES.rst
Outdated
@@ -14,6 +14,8 @@ gaia | |||
|
|||
- Deprecated ``band`` from ``load_data`` as it has no effect on upstream | |||
response any more. [#3278] | |||
- New datalink retrieve types EPOCH_PHOTOMETRY_CROWDED_FIELD, EPOCH_ASTROMETRY_BRIGHT, XP_MEAN_SPECTRUM_GRAVLENS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure these are not included in the rebased version
Fix changelog
Fix changelog
873fc23
to
7ebbcf5
Compare
Small test fix
d2befba
to
12425e2
Compare
Rebased! For some reason, the last line in |
|
||
# Are the two GALEX observations with obs_id 6374399093149532160 in the results table | ||
assert len(result[np.where(result["obs_id"] == "6374399093149532160")]) == 2 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing these assertions as they occasionally break when the number of results increases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Changing the file ending is weird, but not worth going down the rabbit hole to understand it.
This PR handles coordinates passed into query functions that are not in the ICRS frame. If it is found that the given coordinates are not in ICRS, they are transformed.